<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-bean.tld" prefix="bean"%>
<%
	String path = request.getContextPath();
%>
<link href="<%=path%>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/newstyle.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/common.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='<%=path%>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path%>/js/ufront.js'></script>
<script type='text/javascript' src='<%=path%>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path%>/dwr/interface/accountTemplate.js'></script>
<script type='text/javascript' src='<%=path%>/js/vnv/commonForManage.js'></script>
<script type='text/javascript' src='<%=path%>/js/vnv/commonForMutual.js'></script>
<script type='text/javascript' src='<%=path%>/js/vnv/commonForCnAmount.js'></script>
<script type='text/javascript' src='<%=path%>/js/vnv/tomoney.js'></script>
<script language="JavaScript" type="text/JavaScript">
function submitProcess() {
	var formObj = document.forms[0];
	if(checkNecessaryInput(formObj)){
		if (formObj.debitSubAccountId.value == formObj.creditSubAccountId.value){
			alert('请选择不同的子账户');
		} else {
			formObj.submit();
		}
	}
}
function kd(){
	var ss=getObj("amount").value;
	ss = ss.replace(/ /g,"");
	if (ss=="") {
		getObj("upperAmount").value="";
		return;
	}
	
	var sDispMsg = getChineseCurrencyString(ss);
	if(sDispMsg==-1) sDispMsg="错误的金额!";
	if(sDispMsg==-2) sDispMsg="太长的金额!";
	getObj("upperAmount").value=sDispMsg;
}
function updatePrompt(data) {
   if (data==2){
    	alert('此账户没有足够资金，请重新输入！');
    	document.forms[0].amount.value = "";
    	document.forms[0].upperAmount.value = "";
   }else if (data==1){
    	alert('金额输入不正确！');
    	document.forms[0].amount.value = "";
    	document.forms[0].upperAmount.value = "";
   }
}

function setFromMoney(data) {
	getObj('debitSubAccountBalanceSpan').innerHTML = data;
}				

function setToMoney(data) {
	getObj('creditSubAccountBalanceSpan').innerHTML = data;
}	
</script>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="38" background="<%=path%>/images/2007/subtitle_bg.gif">　　<span class="subTitleWhite">子账户转账</span></td>
  </tr>
</table>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="<%=path%>/images/new/page-gray.gif" width="780" height="15" /></td>
  </tr>
</table>

<table width="780" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#DDDFDE">
  <tr>
    <td colspan="2" bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>&nbsp;</td>
        <td width="37" align="center"><img src="<%=path%>/images/2007/1_on.gif" width="37" height="36" /></td>
        <td width="95" class="fontblue14">填写转账信息</td>
        <td width="26" class="fontblue14"><img src="<%=path%>/images/2007/arrow.gif" width="17" height="20" /></td>
        <td width="37"><img src="<%=path%>/images/2007/2_gray.gif" width="37" height="36" /></td>
        <td width="88" class="fontgray14">转账结果</td>
        </tr>
    </table></td>
  </tr>
<html:form method="post" action="subAccountTransfer" >
  <html:hidden property="step"/>
  <tr>
    <td width="23%" background="<%=path%>/images/2007/bg_table.gif" bgcolor="#FFFFFF" class="font_blue">转出子账户：</td>
    <td width="77%" bgcolor="#FFFFFF">
	  <div class="select"><div>
	  <html:select property="debitSubAccountId" onchange="accountTemplate.accountMoney(this.value,setFromMoney)">
		<html:options collection="subAccounts" property="id" labelProperty="accountName" /> 
	  </html:select></div></div>
	</td>
  </tr>
  <tr>
    <td background="<%=path%>/images/2007/bg_table.gif" bgcolor="#FFFFFF" class="font_blue">转出子账户当前余额：</td>
    <td bgcolor="#FFFFFF"><span id="debitSubAccountBalanceSpan" class="subTitleRed"><bean:write name="debitSubAccountBalance"/></span> 元</td>
  </tr>
  <tr>
    <td background="<%=path%>/images/2007/bg_table.gif" bgcolor="#FFFFFF" class="font_blue">转入子账户：</td>
    <td bgcolor="#FFFFFF">
	  <div class="select"><div>
	  <html:select property="creditSubAccountId" onchange="accountTemplate.accountMoney(this.value,setToMoney)">
		<html:options collection="subAccounts" property="id" labelProperty="accountName" /> 
	  </html:select></div></div>
	</td>
  </tr>
  <tr>
    <td background="<%=path%>/images/2007/bg_table.gif" bgcolor="#FFFFFF" class="font_blue">转入子账户余额：</td>
    <td bgcolor="#FFFFFF"><span id="creditSubAccountBalanceSpan" class="subTitleRed"><bean:write name="creditSubAccountBalance"/></span> 元</td>
  </tr>
  <tr>
    <td background="<%=path%>/images/2007/bg_table.gif" bgcolor="#FFFFFF" class="font_blue">转账金额：<span class="org">*</span></td>
    <td bgcolor="#FFFFFF">
      <html:text property="amount" alt="转账金额" size="20" styleClass="inputStyle" style="background:#F6F6F6;" onblur="if(checkDecimalInput(this,0)){accountTemplate.compareAccountMoney(document.forms[0].debitSubAccountId.value,this.value, updatePrompt) ;tomoney('forms[0]','amount','hideTransAmt')}kd();" onkeyup="kd();" onchange="kd();"/>元  
	  <img src="<%=path%>/images/2007/icon.gif" width="17" height="17" border="0" style="cursor:hand" title="请使用计算器，计算转账金额" onclick="amountSelect();"> 
	  <input type="hidden" name="hideTransAmt" value="" />
	</td>
  </tr>
  <tr>
    <td background="<%=path%>/images/2007/bg_table.gif" bgcolor="#FFFFFF" class="font_blue">转账金额大写：</td>
    <td bgcolor="#FFFFFF"><input type="text" name="upperAmount" size="50" class="inputStyleNoborder" style="background:#F6F6F6;" readonly /></td>
  </tr>
</html:form>
</table>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr><td height="25" align="center" class="twoSiderLine">&nbsp;<font color="#FF0000"><html:errors/></font></td></tr>
  <tr>
    <td height="41" align="right" background="<%=path%>/images/2007/page-gray.gif">
      <input type="button" name="next" value="确 定" class="buttonStyle-short" onclick="submitProcess();" />
      &nbsp;&nbsp;&nbsp;&nbsp;
    </td>
  </tr>
</table>
<script type="text/javascript" src="<%=path%>/js/layer.js"></script>
<script language="JavaScript" type="text/JavaScript">
function closeLayer(returnValue, type){
	hideLayer();
	if(type=="amount"){
		document.forms[0].amount.value=returnValue;
		document.forms[0].amount.focus();
		kd();
	}
}

function amountSelect(){
 	agiledata.getUserInternal(amountPopup);
}
function amountPopup(data) {
  	if(data) {
	 	openLayer("<%=path%>/page/common/simpleCalculator.jsp",400,200,false);
	} else {
		location.href="<%=path%>/page/util/session_invalid.jsp";
	}      
}
</script>